#include <iostream>
using std::cout;
using std::endl;

void test0(){
    int num = 100;
    /* &num; */
    //&此时不代表取址符，代表引用符号
    //引用的底层实际是一个常量指针
    int & ref = num;
    ref = 1000;
    cout << num << endl;
    cout << &num << endl;
    cout << &ref << endl;


    cout << endl;
    int num2 = 200;
    //引用一经初始化，无法更改绑定
    ref = num2;//只是赋值
    cout << num << endl;
    cout << &num << endl;
    cout << &ref << endl;
    cout << &num2 << endl;
}

void test1(){
    int num = 10;
    int * p = &num;
    int & ref = num;
    ref = 1000;
    cout << num << endl;
    cout << &num << endl;
    cout << &p << endl;
    cout << &ref << endl;

    //如果不希望通过引用改变其绑定的本体
    //那么可以定义const引用
    const int & ref2 = num;
    /* ref2 = 1000; */
}

int main(void){
    test1();
    return 0;
}
